<?php

/**
 * 合同调用日志
 * @author zhoud 2017-12-28
 */
namespace common\repositories\myhtsq;

use common\repositories\BaseRepository;
use common\support\StringHelper;
use common\entities\myhtsq\ContractApiLogEntity;

class ContractApiLogRepository extends BaseRepository
{

    /**
     * 构造方法
     * @param unknown $config (optional)
     */
    public function __construct($config = [])
    {
        parent::__construct($config);
    }


    /**
     * 新增日志
     * @param common\models\myhtsq\ContractApiLogModel $contractRevenueModel 前端模型
     * @return boolean
     */
    public static function addContractApiLogRecord($contractApiLogModel)
    {
        $contractApiLogEntity = new ContractApiLogEntity();
        $data = $contractApiLogModel->attributes;
        $contractApiLogEntity->load($data, '');
        $contractApiLogEntity->log_id = StringHelper::uuid();
        $contractApiLogEntity->log_type = $contractApiLogModel->log_type;
        $contractApiLogEntity->call_method = $contractApiLogModel->call_method;
        $contractApiLogEntity->call_parametes = $contractApiLogModel->call_parametes;
        $contractApiLogEntity->return_data = $contractApiLogModel->return_data;
        $contractApiLogEntity->return_code = $contractApiLogModel->return_code;
        $contractApiLogEntity->error_msg = $contractApiLogModel->error_msg;
        $contractApiLogEntity->maintain_remark = $contractApiLogModel->maintain_remark;
        if ($contractApiLogEntity->save()) {
            return $contractApiLogEntity->log_id;
        } else {
            return false;
        }
    }

}